package com.dynaBlaster.containerTest;

import android.content.Context;
import android.test.ActivityInstrumentationTestCase2;

import com.dynaBlaster.BoardView;
import com.dynaBlaster.DynaBlaster;
import com.dynaBlaster.DynaView;
import com.dynaBlaster.Point;
import com.dynaBlaster.DynaView.Area;

public class  FullBoardTest extends BaseAndroidSuite {

	private DynaView board;

	public  FullBoardTest() {
		super();
	}

	@Override
	public void setUp() throws Exception {
		super.setUp();

		DynaView.BOARD_CLEAR = false;

		board = mView;
		board.initWalls();
		board.initBoard();
	}

	public void testTest() {

		assertNotNull(board);

	}

	public void testHeroNotBlocked() {
		
		Point p1 = new Point(DynaView.HERO_START_X, DynaView.HERO_START_Y);
		Point p2 = new Point(DynaView.HERO_START_X + 1, DynaView.HERO_START_Y);
		Point p3 = new Point(DynaView.HERO_START_X, DynaView.HERO_START_Y + 1);
		
		assertEquals(Area.FREE.nr, board.getTile(p1 ));
		assertEquals(Area.FREE.nr, board.getTile(p2 ));
		assertEquals(Area.FREE.nr, board.getTile(p3 ));

	}
	
	public void testFreeCount() {
		int count = 0;
		for (int i = 0; i < board.mXTileCount; i++) {
			for (int j = 0; j < board.mYTileCount; j++) {
				int tile = board.getTile(new Point(i, j));
				if ( ((tile == Area.FREE.nr) )) {
					count++;
				}
			}
		}
		
		int ratio = (int) ((board.mXTileCount*board.mYTileCount)*0.3);
		assertTrue("not enough free:"+count+"expected: "+ratio,ratio<= count );

	}
	
	 
}